﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UserGUI : MonoBehaviour
{
    IUserAction userAction;
    string gameMessage;
    int points;

    int game_mode = 0;
    string game_mode_text = "普通模式";

    int motion_mode = 0;
    string motion_mode_text = "运动学";

    public void SetMessage(string gameMessage)
    {
        this.gameMessage = gameMessage;
    }

    public void SetPoints(int points)
    {
        this.points = points;
    }

    void Start()
    {
        points = 0;
        gameMessage = "";
        userAction = SSDirector.GetInstance().CurrentScenceController as IUserAction;
    }

    void OnGUI()
    {
        //小字体初始化
        GUIStyle style = new GUIStyle();
        style.normal.textColor = Color.white;
        style.fontSize = 30;

        //大字体初始化
        GUIStyle bigStyle = new GUIStyle();
        bigStyle.normal.textColor = Color.white;
        bigStyle.fontSize = 50;

        GUI.Label(new Rect(300, 30, 50, 200), "Hit UFO", bigStyle);
        GUI.Label(new Rect(20, 0, 100, 50), "Points: " + points, style);
        GUI.Label(new Rect(310, 100, 50, 200), gameMessage, style);
        if (GUI.Button(new Rect(20, 50, 100, 40), "Restart"))
        {
            userAction.Restart();
        }
        if (GUI.Button(new Rect(20, 100, 100, 40), game_mode_text))
        {
            if(game_mode == 0){
                game_mode = 1;
                userAction.SetMode(true);
                game_mode_text = "无限模式";
            }
            else if(game_mode == 1){
                game_mode = 0;
                userAction.SetMode(false);
                game_mode_text = "普通模式";
            }
            
        }
        if (GUI.Button(new Rect(20, 150, 100, 40), motion_mode_text))
        {
            if(motion_mode == 0){
                motion_mode = 1;
                userAction.SetFlyMode(true);
                motion_mode_text = "物理运动";
            }
            else if(motion_mode == 1){
                motion_mode = 0;
                userAction.SetFlyMode(false);
                motion_mode_text = "运动学";
            }

        }
        if (Input.GetButtonDown("Fire1"))
        {
            userAction.Hit(Input.mousePosition);
        }
        GUI.Label(new Rect(20, 250, 100, 40), "红：1分", style);
        GUI.Label(new Rect(20, 300, 100, 40), "绿：2分", style);
        GUI.Label(new Rect(20, 350, 100, 40), "蓝：3分", style);
    }
}
